package com.ruoyi.pingjiao.service.impl;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.pingjiao.domain.CourseclassTeacher;
import com.ruoyi.pingjiao.domain.Student;
import com.ruoyi.pingjiao.mapper.CourseclassTeacherMapper;
import com.ruoyi.pingjiao.service.ICourseclassTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 教师上课Service业务层处理
 * 
 * @author 牛亚博
 * @date 2023-07-08
 */
@Service
public class CourseclassTeacherServiceImpl implements ICourseclassTeacherService
{
    @Autowired
    private CourseclassTeacherMapper courseclassTeacherMapper;

    @Override
    public List<Student> selectCourseclassStudentList(Long courseclass_id) {
        return courseclassTeacherMapper.selectCourseclassStudentList(courseclass_id);
    }

    /**
     * 查询教师上课
     * 
     * @param teacherId 教师上课主键
     * @return 教师上课
     */
    @Override
    public CourseclassTeacher selectCourseclassTeacherByTeacherId(Long teacherId)
    {
        return courseclassTeacherMapper.selectCourseclassTeacherByTeacherId(teacherId);
    }

    /**
     * 查询教师上课列表
     * 
     * @param courseclassTeacher 教师上课
     * @return 教师上课
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "o1")
    public List<CourseclassTeacher> selectCourseclassTeacherList(CourseclassTeacher courseclassTeacher)
    {
        return courseclassTeacherMapper.selectCourseclassTeacherList(courseclassTeacher);
    }

    /**
     * 新增教师上课
     * 
     * @param courseclassTeacher 教师上课
     * @return 结果
     */
    @Override
    public int insertCourseclassTeacher(CourseclassTeacher courseclassTeacher)
    {
        return courseclassTeacherMapper.insertCourseclassTeacher(courseclassTeacher);
    }

    /**
     * 修改教师上课
     * 
     * @param courseclassTeacher 教师上课
     * @return 结果
     */
    @Override
    public int updateCourseclassTeacher(CourseclassTeacher courseclassTeacher)
    {
        int a =  courseclassTeacherMapper.updateCourseclassTeacher(courseclassTeacher);
        if(a == 0){
            return this.insertCourseclassTeacher(courseclassTeacher);
        }else{
            return a;
        }
//        return courseclassTeacherMapper.updateCourseclassTeacher(courseclassTeacher);
    }

    /**
     * 批量删除教师上课
     * 
     * @param teacherIds 需要删除的教师上课主键
     * @return 结果
     */
    @Override
    public int deleteCourseclassTeacherByTeacherIds(Long[] teacherIds)
    {
        return courseclassTeacherMapper.deleteCourseclassTeacherByTeacherIds(teacherIds);
    }

    /**
     * 删除教师上课信息
     * 
     * @param teacherId 教师上课主键
     * @return 结果
     */
    @Override
    public int deleteCourseclassTeacherByTeacherId(Long teacherId)
    {
        return courseclassTeacherMapper.deleteCourseclassTeacherByTeacherId(teacherId);
    }
}
